var express = require('express');
var router = express.Router();
const shopsService = require("../service/shopsService");

router.get("/", async function (req, res, next) {
    const data = await shopsService.getShops();
    res.send(data);
})

router.delete('/', async function (req, res, next) {
    const shop = req.body;
    const _id = shop._id;
    const data = await shopsService.deleteShops(_id);
    res.send(data);
});

router.post('/', async function (req, res, next) {
    const shop = req.body;

    const data = await shopsService.insertShops(shop);
    res.send(data);
});

router.put('/', async function (req, res, next) {
    const shop = req.body;

    const data = await shopsService.updataShops(shop);
    res.send(data);
});


module.exports = router;